require 'rake'

module Rubicant

  class Runner
    def self.run(command)
      puts command unless ENV['debug'].nil?
      sh command
    end

    def self.exec(program, opts={})
      fail("program is required") if program.nil? || program.length == 0
      command = ""
      command << opts[:program_dir] unless opts[:program_dir].nil?
      command << "/" if command.length > 0 && command.rindex("/") != command.length - 1
      command << program + " "
      command << opts[:args].join(" ") unless opts[:args].nil?

      working_dir = Dir.pwd
      working_dir = opts[:working_dir] unless opts[:working_dir].nil?

      Dir.chdir(working_dir) do |path|
        Runner.run(command)
      end
    end


  end

  class Files
    def self.copy(src, dest, opts={})
      cp src, dest, opts
    end

    def self.remove(list, options={})
      rm list, options
    end
  end
    
end